package cn.ljy.authority.dao.mapper;

import cn.ljy.authority.dao.BaseMapper;
import cn.ljy.authority.model.SysDict;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.io.Serializable;

@Mapper
public interface SysDictMapper extends BaseMapper<SysDict> {
    /**
     * 根据名称查找数据库中重名的数量
     * @param name
     * @return 返回重名数
     */
    @Select("select count(1) from sys_dict where name=#{name}")
    int countByName(String name);

    /**
     * 根据名称查找数据库中重名的数量
     * @param name
     * @param id
     * @return 返回重名数
     */
    @Select("select count(1) from sys_dict where name=#{name} and id!=#{id}")
    int countByNameAndIdNot(String name, Serializable id);
}
